home *** CD-ROM | disk | FTP | other *** search
/ The Complete Utilities To…ka 501 Killer Utilities! / 501 Killer Utilities! (Macworld July 1995).cdr / Programming / Little Smalltalk v3.1.4 / C Source / Headers / glue.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-23  |  8.1 KB  |  232 lines  |  [TEXT/KAHL]

  1. /*
  2.     Little Smalltalk, version 2
  3.     Written by Tim Budd, Oregon State University, July 1987
  4.  
  5.     Symantec Think Class Library interface code ©Julian Barkway, April 1994 
  6.     
  7.     glue.h 
  8.     ------
  9.     Structures, #defines and prototypes relating to the Little Smalltalk-TCL 
  10.     interface. Currently, this header is largely identifier-compatible with 
  11.     StdWin. However, this may change in future.
  12. */
  13. #ifndef __GLUE_H__
  14. #define __GLUE_H__
  15.  
  16. #define CURSOR Cursor
  17. #define WINDOW    _window    // These will be used as a pointer to the memory containing
  18. #define TEXTEDIT char    // the real data and should be casted.
  19. #define MENU    MenuInfo
  20.  
  21. typedef struct _window {
  22.     char    *window;
  23.     char    *document;
  24. } _window;
  25.  
  26. //
  27. //====== The following definitions and prototypes have been taken from
  28. //====== Guido van Rossum's StdWin system for reasons of compatibility.
  29. //
  30. /* EVENT struct */
  31.  
  32. struct _event {
  33.     int type;
  34.     WINDOW *window;
  35.     union {
  36.         int character;                                        /* case WE_CHAR: */
  37.         int command;                                        /* case WE_COMMAND: */
  38.         struct { int id; int item; } m;                        /* case WE_MENU: */
  39.         struct { int left, top, right, bottom; } area;        /* case WE_DRAW: */
  40.         struct {                    /* case WE_MOUSE_DOWN, WE_MOUSE_MOVE, WE_MOUSE_UP: */
  41.             int h;
  42.             int v;
  43.             int clicks;
  44.             int button;
  45.             int mask;
  46.         } where;
  47.         int sel;                                            /* case WE_LOST_SEL: */
  48.         struct { int code; int mask; } key;                    /* case WE_KEY: */
  49.     } u;
  50. };
  51.  
  52. #define EVENT struct _event
  53.  
  54.  
  55. /* Event types */
  56. /* XXX Should be reordered */
  57.  
  58. #define WE_NULL        0        /* (Used internally) */
  59. #define WE_ACTIVATE    1        /* Window became active */
  60. #define WE_CHAR        2        /* Character typed at keyboard */
  61. #define WE_COMMAND    3        /* Special command, function key etc. */
  62. #define WE_MOUSE_DOWN    4    /* Mouse button pressed */
  63. #define WE_MOUSE_MOVE    5    /* Mouse moved with button down */
  64. #define WE_MOUSE_UP    6        /* Mouse button released */
  65. #define WE_MENU        7        /* Menu item selected */
  66. #define WE_SIZE        8        /* Window size changed */
  67. #define WE_MOVE        9        /* Window moved (reserved) */
  68. #define WE_DRAW        10        /* Request to redraw part of window */
  69. #define WE_TIMER    11        /* Window's timer went off */
  70. #define WE_QUIT        11            // -- Since the use of the timer is not supported
  71.                                 //    by Little Smalltalk, I am using this event to
  72.                                 //    pass the command-Q (quit) notification from 
  73.                                 //    TCL to Little Smalltalk. JRB, 5/94
  74. #define WE_DEACTIVATE    12    /* Window became inactive */
  75. #define WE_EXTERN    13        /* Externally generated event (Amoeba) */
  76. #define WE_KEY        14        /* Non-ASCII key event */
  77. #define WE_LOST_SEL    15        /* Lost selection */
  78. #define WE_CLOSE    16        /* User wants to close window */
  79.  
  80.  
  81. /* Special keys reported by WE_COMMAND */
  82. /* XXX Should become key events */
  83.  
  84. #define WC_CLOSE    1        /* Obsolete */
  85. /* The following four are arrow keys */
  86. #define WC_LEFT        2
  87. #define WC_RIGHT    3
  88. #define WC_UP        4
  89. #define WC_DOWN        5
  90. /* ASCII keys */
  91. #define WC_CANCEL    6
  92. #define WC_BACKSPACE    7
  93. #define WC_TAB        8
  94. #define WC_RETURN    9
  95. /* IBM-PC keys -- not in all implementations */
  96. /* XXX Should be done differently */
  97. #define WC_HOME        10
  98. #define WC_END        11
  99. #define WC_CLEAR    12
  100. #define WC_INS        13
  101. #define WC_DEL        14
  102. #define WC_PAGE_UP    15
  103. #define WC_PAGE_DOWN    16
  104. #define WC_META_LEFT    17
  105. #define WC_META_RIGHT    18
  106. #define WC_META_HOME    19
  107. #define WC_META_END    20
  108. #define WC_META_PAGE_UP    21
  109. #define WC_META_PAGE_DOWN    22
  110. /* XXX Should have entries for Alt-letter and F1-F10 etc. ? */
  111.  
  112.  
  113. /* Codes for selections (e.u.sel for WE_LOST_SEL) */
  114.  
  115. #define WS_CLIPBOARD    0
  116. #define WS_PRIMARY    1
  117. #define WS_SECONDARY    2
  118.  
  119.  
  120. /* Masks for EVENT->u.where.mask and EVENT->u.key.mask.
  121.    Some of these happen to be the same as the X11 masks (which are cast
  122.    in stone for eternity); the implementation relies on that.
  123.    (It is merely a convention that Meta is bit 3, and Option/Num aren't
  124.    normally used in X11.) */
  125.  
  126. #define WM_SHIFT    (1 << 0)
  127. #define WM_LOCK        (1 << 1)
  128. #define WM_CONTROL    (1 << 2)
  129. #define WM_META        (1 << 3)
  130. #define WM_OPTION    (1 << 4)
  131. #define WM_NUM        (1 << 5)
  132.  
  133. #define WM_BUTTON1    (1 << 8)
  134. #define WM_BUTTON2    (1 << 9)
  135. #define WM_BUTTON3    (1 << 10)
  136. #define WM_BUTTON4    (1 << 11)
  137. #define WM_BUTTON5    (1 << 12)
  138.  
  139.  
  140. //====================== Function Prototypes =========================
  141.  
  142. void     winit                 (void);
  143. void     getVersionNumber     (char *str);
  144. void     wdone                 (void);
  145. void     setFont                (TEXTEDIT *tp, char *fontName);
  146. void     setFontSize            (TEXTEDIT *tp, short fontSize);
  147. void     setTypeFace            (TEXTEDIT *tp, short typeFace);
  148. void     tereplace             (TEXTEDIT *tp, char *str);
  149. void    replaceAllText        (TEXTEDIT *tp, char *str);
  150. void     deleteAllText         (TEXTEDIT *tp);
  151. void    getPaneSize            (TEXTEDIT *tp, short *width, short *height);
  152. TEXTEDIT *addScrollPane     (WINDOW *win, short left, short top, short right, short bottom,
  153.                                 short horizOption, short vertOption);
  154. TEXTEDIT *addSelPane        (WINDOW *win, short left, short top, short right, short bottom,
  155.                                short horizElastic, short vertElastic, short lineLength);
  156. TEXTEDIT *addTextPane         (WINDOW *win, short left, short top, short right, short bottom,
  157.                                short horizElastic, short vertElastic, short lineLength);
  158. TEXTEDIT *tecreate            (WINDOW *win, int left, int top, int right, int bottom);
  159. TEXTEDIT *addGraphicsPane     (WINDOW *win, short left, short top, short right, short bottom,
  160.                                short horizElastic, short vertElastic);
  161. Boolean teevent                (TEXTEDIT *tp, EVENT *e);
  162. void    scrollToSelection    (TEXTEDIT *tp);
  163. void    setTextSelection    (TEXTEDIT *tp, long startPos, long endPos);
  164. void    getTextSelection    (TEXTEDIT *tp, long *startPos, long *endPos);
  165. char    *teGetSelectedText    (TEXTEDIT *tp);
  166. char     *tegettext            (TEXTEDIT *tp);
  167. void     tedraw                (register TEXTEDIT *tp);
  168.  
  169. void     wmessage            (char *prompt);
  170. void     wperror                (char *name);
  171. Boolean waskstr                (char *prompt, char *buf, int len);
  172. int     waskync                (char *prompt, int def);
  173. Boolean waskfile             (char *prompt, char *buf, int len, Boolean newFile, short ftype);
  174. void     saveTE                (TEXTEDIT *tp, short fileNum);
  175. void     loadTE                (TEXTEDIT *tp, short fileNum);
  176.  
  177. void     wmenuenable         (MENU *mp, int item, int flag);
  178. MENU     *wmenucreate        (int id, char *title);
  179. MENU     *popUpMenuCreate    (short menuID);
  180. void     wmenuattach         (WINDOW *win, MENU *mp);
  181. void     wmenudetach         (WINDOW *win, MENU *mp);
  182. void     wmenucheck            (MENU *mp, int item, int flag);
  183. void     wmenusetdeflocal    (Boolean local);
  184. int     wmenuadditem        (MENU *mp, char *text, int shortcut);
  185. void     selectFromPopUpMenu (MENU *mp, short top, short left, short *menu, short *item);
  186. void     wmenudelete         (MENU *mp);
  187. void     removeMenuItem        (MENU *mp, short menuItem);
  188.  
  189. void     getMaxScreenArea     (short *left, short *top, short *right, short *bottom);
  190. CURSOR    *wfetchcursor        (char *name);
  191. void    wsetwincursor        (WINDOW *win, CURSOR *cursor);
  192. void    setArrowCursor        (void);
  193.  
  194. Boolean    docDirty            (WINDOW *win);
  195. void     wsetdocsize            (WINDOW *win, int docwidth, int docheight);
  196. void     wsetactive            (WINDOW *win);
  197. WINDOW     *wopen                (char *title, 
  198.                              void (*drawproc)(WINDOW *win, int top, int left,
  199.                                            int bottom, int right) );
  200. WINDOW *wopentosize            (char *title, int left, int top, int width, int height);
  201. void     wfleep                (void);
  202. void     wclose                (WINDOW *win);
  203. void     wgetwinsize            (WINDOW *win, int *pwidth, int *pheight);
  204. void     wgetwinpos            (WINDOW *win, int *h, int *v);
  205. void     windowToFront         (WINDOW *win);
  206. void     wsettitle            (WINDOW *win, Str255 title);
  207. void     wsetorigin             (WINDOW *win, int orgh, int orgv);
  208.  
  209. void    wbegindrawing        (TEXTEDIT *pane);
  210. void     wenddrawing            (TEXTEDIT *pane);
  211. void     wshade                (int left, int top, int right, int bottom, int perc);
  212. void     werase                 (int left, int top, int right, int bottom);
  213. void     wdrawcircle            (int h, int v, int radius);
  214. void     drawLineTo            (int h, int v);
  215. void     moveTo                (short h, short v);
  216. void     drawPixel            (short h, short v);
  217. void     wdrawbox            (int left, int top, int right, int bottom);
  218. void     winvert                (int left, int top, int right, int bottom);
  219. void     wpaint                (int left, int top, int right, int bottom);
  220. void     wdrawtext            (int h, int v, char *str, int len);
  221. void     wdrawchar            (int h, int v, int c);
  222.  
  223. OSErr     sendOpenDocEvent    (long theAppSig, SFReply *theSFReply);
  224. Boolean getFileInfo            (char *fullPath, long *fType);
  225.  
  226. Boolean processStartUpEvent (char *buf);
  227.  
  228. void     wgetevent            (EVENT *ep);
  229. void     processMouseDown    (EventRecord *macEvent, EVENT *ep);
  230. void     wsettimer            (WINDOW *win, int deciseconds);
  231. #endif
  232.